-- the handler for the DoSearch message is in the script of
-- this stack
end mouseUp
-- part 10 (button)
-- low flags: 00
-- high flags: A003
-- rect: left=299 top=300 right=322 bottom=438
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Show Pascal Source
----- HyperTalk script -----
on mouseUp
set the visible of card field 1 to not the visible of card field 1
if the visible of card field 1 is true then
set the name of me to "Hide Pascal Source"
else set the name of me to "Show Pascal Source"
end mouseUp
-- part contents for background part 16
----- text -----
MODALDIALOG XFCN version 1.0.3
Kevin Calhoun
ModalDialog displays a dialog box created by any resource generator or editor, such as ResEdit. It permits the user to interact with the dialog in the standard Macintosh fashion and, once the user dismisses the dialog, returns information about the contents of all the editable text items and the state of all the check boxes and radio buttons at the time the dialog was dismissed.
INVOKING MODALDIALOG
get ModalDialog("DLOGName",<containerName>,<dialogPositioning>,<noCancel>,<noWordWrap>)
returns
if the user presses the default button: a multi-lined expression, explained below,
describing the contents of the dialog box
if the user presses the cancel button: "Cancel"
if an error occurs: "Error " followed by an error code
WHAT YOU PASS TO MODALDIALOG
You tell ModalDialog which dialog to display by passing the name of its DLOG resource in the first parameter. For example, ModalDialog("ask") brings up HyperCard's ask dialog. You should enclose this name in quotation marks.
The rest of the parameters are optional.
The second parameter, containerName, is the name of a HyperTalk container. Before calling ModalDialog, you can store a multi-lined expression in this container that will determine the following properties of the dialog: the text of text items, the initial state of check boxes and radio buttons, the grouping of radio buttons, and the default and cancel buttons. The container should include one line for each dialog item in the DITL resource--ModalDialog matches each dialog item with the corresponding line in the container. If there is no second parameter, or if it is empty, then the dialog will appear in the default state: the text items will contain the text specified by the DITL, check boxes and radio buttons will be turned off, all radio buttons will be grouped together, the default button will be the first button in the DITL, and the cancel button will be the second button in the DITL. The next few paragraphs explain how to override this default behavior.
If the dialog item is a button control, ModalDialog looks in its corresponding line in containerName for two items:
defaultOrCancel,Name
If defaultOrCancel is "Default", the button becomes the default button (the one that's pushed when the user presses the return or enter key) and the familiar bold outline will be drawn around it. If defaultOrCancel is "Cancel", the button becomes the cancel button (the one that's pushed when the user presses the escape key, command-period, or command-Q). If more than one button is designated the default button, the last of these in the list becomes the actual default button. The same rule applies for multiple buttons designated the cancel button. If Name is not empty, then the title of the button will be set to it.
If the dialog item is a check box, ModalDialog looks in its corresponding line in containerName for two items:
onOrOff,Name
If onOrOff is "On", the check box will be checked when it first appears. If Name is not empty, the title of the check box will be set to it.
If the dialog item is a radio button, ModalDialog looks in its corresponding line in containerName for three items:
onOrOff,group,Name
If onOrOff is "On", the radio button will be on when it first appears. Group is a number that tells ModalDialog which radio buttons should be turned off when the user turns the radio button on. When the user clicks a radio button, ModalDialog does nothing if the radio button is already on; if it's off, every other radio button with the same group number is turned off before it's turned on. If group is empty, the radio button is assigned to group number 0. (Note: ModalDialog doesn't check whether you turn more than one radio button on within the same group. If you do this, the radio buttons in that group will not behave normally.) If Name is not empty, the title of the radio button will be set to it.
If the dialog item is an editable text item, ModalDialog looks in its corresponding line in containerName for two items:
text,select
If text is not empty, the text of the dialog item will be set to it. If select is "Select", the text of the item will be selected. If more than one text item is designated the selected item, the last of these in the list will actually be selected when the dialog appears. If none of the dialog items is selected in this fashion, the first edit item in the list will be selected when the dialog appears.
If the dialog item is a static text item, ModalDialog will set the text of the dialog item to the line in containerName that corresponds to it, unless that line is empty.
If the dialog item is an icon item, a picture item, a user item, or a control defined by a resource template in a resource file, ModalDialog ignores the line in containerName that corresponds to it.
The third parameter, dialogPositioning, tells ModalDialog how to position the dialog on the screen, as follows.
"cardOffset" coordinates in DLOG resource are treated as local to the card
"cardCenter" the dialog is centered over the card window
"screenCenter" the dialog is centered on the main screen
In addition, each of these options may be preceded by an "h" or a "v", with the following effects: "h" tells ModalDialog to alter only the horizontal positioning of the dialog, while "v" tells it to alter only the vertical positioning. For example, "hScreenCenter" will cause the dialog to be centered horizontally on the screen while retaining the vertical positioning specified in the DLOG resource. If there is no third parameter, or if it is something other than these options, the coordinates ModalDialog finds in the DLOG resource are treated as global coordinates and become the dialog's bounding rectangle.
(Note: for compatibility with earlier versions, TRUE means the same thing as
"cardOffset".)
The fourth parameter, noCancel, tells ModalDialog whether or not there is a cancel item. If noCancel is TRUE, the user cannot dismiss the dialog by pressing command-period, command-Q, or the escape key, or by pressing any button other than the default item. If noCancel is not present, or if it is anything other than TRUE, then the cancel item is determined by the methods described above and the dialog can be cancelled.
The fifth parameter, noWordWrap, tells ModalDialog whether or not you want automatic word wrapping in edit text items. If it is TRUE, there will be no word wrap. If it is absent or anything other than TRUE, the words will wrap.
WHAT MODALDIALOG RETURNS
If the user dismisses the dialog by clicking the default item or by pressing return or enter, ModalDialog returns a multi-line expression, one line per item in the dialog item list, describing what the dialog contained when it was dismissed.
If the item is a check box or a radio button, the line corresponding to it will contain "off" if the button was off and "on" if the button was on.
If the item is an edit text item, the line corresponding to it will contain the text of the item.
If the item is any other type of dialog item, the line corresponding to it will be empty.
If the user dismisses the dialog by clicking the cancel item or by pressing command-period, command-Q, or the escape key, then ModalDialog returns "Cancel".
REVISION HISTORY
March 15, 1989 -- 1.0 release.
March 31, 1989 -- 1.0.1. Sped up scanning of input container. Container name should no longer be quoted. Default group for radio buttons is now 0, not 1.
April 3, 1989 -- 1.0.2. Added pre-flight check for presence of DITL resource. Added more options for dialog positioning.
June 25, 1989 -- 1.0.3. If user copies a selection from an edit text item in the dialog, the desk scrap will contain that text after the dialog is dismissed.
-- part contents for card part 3
----- text -----
UNIT ModalDialogUnit;
{ ModalDialog XCMD ©1989 by the Trustees of Dartmouth College }